<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Cache-Control" content="no-store"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
    <title></title>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=v1ynHS570GgGL2HinECWssLGx6U1AOIE"></script>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#load_geolocation").click(function (ev) {
                $(ev.currentTarget).text("正在获取位置......");
                //创建百度地图控件
                var geolocation = new BMap.Geolocation();
                geolocation.getCurrentPosition(function (r) {
                    if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                        //以指定的经度与纬度创建一个坐标点
                        var pt = new BMap.Point(r.point.lng, r.point.lat);
                        //创建一个地理位置解析器
                        var geoc = new BMap.Geocoder();
                        geoc.getLocation(pt, function (rs) {//解析格式：城市，区县，街道
                            var addComp = rs.addressComponents;
                            $(ev.currentTarget).text(addComp.city + ", " + addComp.district + ", " + addComp.street);
                        });
                    }
                    else {
                        $(ev.currentTarget).text('定位失败');
                    }
                }, {enableHighAccuracy: true})//指示浏览器获取高精度的位置，默认false
            });
        });


    </script>
</head>
<body class="easyui-layout">

<body>
<div>
    <span id="load_geolocation">点击获取位置</span>
</div>
</body>

</body>
</html>